<template>
  <div class="page-account">
    <div class="container" :class="[fullWidth > 768 ? 'containerSamll' : 'containerBig']">
<!--      <swiper :options="swiperOption" class="swiperPross" v-if="fullWidth > 768">-->
<!--        <swiper-slide class="swiperPic" v-for="(item, index) in swiperList" :key="index">-->
<!--          <img :src="item.slide" />-->
<!--        </swiper-slide>-->
<!--        <div class="swiper-pagination" slot="pagination"></div>-->
<!--      </swiper>-->
      <div class="index_from page-account-container from-wh">
        <div class="page-account-top">
          <div class="page-account-top-logo">
<!--            <img :src="login_logo" alt="logo" style="width: 100%; height: 74px" />-->
          </div>
        </div>
        <Form ref="formInline" :model="formInline" :rules="ruleInline" @keyup.enter="handleSubmit('formInline')">
          <FormItem prop="username">
            <Input
              type="text"
              v-model="formInline.username"
              prefix="ios-contact-outline"
              placeholder="请输入用户名"
              size="large"
            />
          </FormItem>
          <FormItem prop="password">
            <Input
              type="password"
              v-model="formInline.password"
              prefix="ios-lock-outline"
              placeholder="请输入密码"
              size="large"
            />
          </FormItem>
<!--          <FormItem prop="code">-->
<!--            <div class="code">-->
<!--              <Input-->
<!--                type="text"-->
<!--                v-model="formInline.code"-->
<!--                prefix="ios-keypad-outline"-->
<!--                placeholder="请输入验证码"-->
<!--                size="large"-->
<!--              />-->
<!--              <img :src="imgcode" class="pictrue" @click="captchas" />-->
<!--            </div>-->
<!--          </FormItem>-->
          <FormItem>
            <Button type="primary" long :loading="loading" size="large" @click="handleSubmit('formInline')" class="btn"
              >登录</Button
            >
          </FormItem>
        </Form>
      </div>
    </div>
    <!-- <Modal
      v-model="modals"
      scrollable
      footer-hide
      closable
      title="请完成安全校验"
      :mask-closable="false"
      :z-index="2"
      width="342"
    >
      <div class="captchaBox">
        <div id="captcha" style="position: relative" ref="captcha"></div>
        <div id="msg"></div>
      </div>
    </Modal> -->
    <vcode :show="isShow" @success="closeModel()" @close="closeModel()" successText="验证通过" />
  </div>
</template>
<script>
import { AccountLogin, loginInfoApi } from '@/api/account';
import { getWorkermanUrl } from '@/api/kefu';
// import mixins from '../mixins'
import Setting from '@/setting';
import { setCookies } from '@/libs/util';
import '../../../assets/js/canvas-nest.min';
// import '../../../assets/js/jigsaw.js';
import Vcode from 'vue-puzzle-vcode';
export default {
  // mixins: [mixins],
  components: {
    Vcode,
  },
  data() {
    return {
      fullWidth: document.documentElement.clientWidth,
      swiperOption: {
        pagination: '.swiper-pagination',
        autoplay: true,
      },
      loading: false,
      isShow: false,
      autoLogin: true,
      imgcode: '',
      formInline: {
        username: '',
        password: '',
        code: '',
      },
      ruleInline: {
        username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
        code: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
      },
      errorNum: 0,
      // jigsaw: null,
      login_logo: '',
      swiperList: [],
      defaultSwiperList: require('@/assets/images/sw.jpg'),
      key: '',
    };
  },
  created() {
    var _this = this;
    top != window && (top.location.href = location.href);
    document.onkeydown = function (e) {
      if (_this.$route.name === 'login') {
        let key = window.event.keyCode;
        if (key === 13) {
          _this.handleSubmit('formInline');
        }
      }
    };
    window.addEventListener('resize', this.handleResize);
  },
  watch: {
    fullWidth(val) {
      // 为了避免频繁触发resize函数导致页面卡顿，使用定时器
      if (!this.timer) {
        // 一旦监听到的screenWidth值改变，就将其重新赋给data里的screenWidth
        this.screenWidth = val;
        this.timer = true;
        let that = this;
        setTimeout(function () {
          // 打印screenWidth变化的值
          that.timer = false;
        }, 400);
      }
    },
    $route(n) {
      // this.captchas();
    },
  },
  mounted: function () {
    this.$nextTick(() => {
      // /* eslint-disable */
      let that = this;
      // this.jigsaw = jigsaw.init({
      //   el: this.$refs.captcha,
      //   onSuccess() {
      //     that.modals = false;
      //     that.closeModel();
      //   },
      //   onFail: this.closefail,
      //   onRefresh() {},
      // });
      if (this.screenWidth < 768) {
        document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
      } else {
        document.getElementsByTagName('canvas')[0].className = 'index_bg';
      }
      // this.swiperData();
    });
    // this.captchas();
  },
  methods: {
    swiperData() {
      loginInfoApi()
        .then((res) => {
          localStorage.setItem('ADMIN_TITLE', res.data.site_name);
          let data = res.data || {};
          this.login_logo = data.login_logo ? data.login_logo : require('@/assets/images/logo.png');
          this.swiperList = data.slide.length ? data.slide : [{ slide: this.defaultSwiperList }];
          this.key = data.key;
        })
        .catch((err) => {
          this.$Message.error(err);
          this.login_logo = require('@/assets/images/logo.png');
          this.swiperList = [{ slide: this.defaultSwiperList }];
        });
    },
    // 关闭模态框
    closeModel() {
      this.isShow = false;
      let msg = this.$Message.loading({
        content: '登录中...',
        duration: 0,
      });
      this.loading = true;
      AccountLogin({
        name: this.formInline.username,
        // account: this.formInline.username,
        pwd: this.formInline.password,
        // imgcode: this.formInline.code,
        // key: this.key,
      })
        .then(async (res) => {
          msg();
          let token = res.data.token;
          res = {
            "status": 200,
            "msg": "success",
            "data": {
              // "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJsb2NhbC5mYW1pbHkuY29tOjk3NjMiLCJhdWQiOiJsb2NhbC5mYW1pbHkuY29tOjk3NjMiLCJpYXQiOjE3MTgyNjQxMDgsIm5iZiI6MTcxODI2NDEwOCwiZXhwIjoxNzIwODU2MTA4LCJqdGkiOnsiaWQiOjIsInR5cGUiOiJhZG1pbiJ9fQ.96JqMoloVBsWEr7iw7Suyoy8WSzx45yM4-cipnEotWA",
              "expires_time": 1720856108,
              "menus": [
                {
                  "path": "\/admin\/home\/",
                  "title": "数据总览",
                  "icon": "md-home",
                  "header": "home",
                  "is_header": 1
                },
                {
                  "path": "\/admin\/product",
                  "title": "加梯申请投票",
                  "icon": "md-basket",
                  "header": "0",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/product\/product_list",
                      "title": "商品管理",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/product\/product_classify",
                      "title": "商品分类",
                      "icon": "",
                      "header": "product",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/product\/add_product",
                      "title": "产品添加",
                      "icon": "",
                      "header": "product",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    },
                    {
                      "path": "\/admin\/product\/product_attr",
                      "title": "商品规格",
                      "icon": "",
                      "header": "product",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/product\/product_reply",
                      "title": "商品评论",
                      "icon": "",
                      "header": "product",
                      "is_header": 0
                    }
                  ]
                },
                {
                  "path": "\/admin\/order",
                  "title": "房本信息处理",
                  "icon": "md-cart",
                  "header": "home",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/order\/list",
                      "title": "订单管理",
                      "icon": "",
                      "header": "order",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/order\/offline",
                      "title": "收银订单",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/order\/refund",
                      "title": "售后订单",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    }
                  ]
                },
                {
                  "path": "\/admin\/agent",
                  "title": "建议意见管理",
                  "icon": "ios-people",
                  "header": "user",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/setting\/system_config_retail\/2\/9",
                      "title": "分销设置",
                      "icon": "",
                      "header": "setting",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/agent\/agent_manage\/index",
                      "title": "分销员管理",
                      "icon": "",
                      "header": "user",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/setting\/membership_level\/index",
                      "title": "分销等级",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/agent\/division",
                      "title": "事业部",
                      "icon": "",
                      "header": "",
                      "is_header": 0,
                      "children": [
                        {
                          "path": "\/admin\/division\/index",
                          "title": "事业部列表",
                          "icon": "",
                          "header": "",
                          "is_header": 0
                        },
                        {
                          "path": "\/admin\/division\/agent\/index",
                          "title": "代理商列表",
                          "icon": "",
                          "header": "",
                          "is_header": 0
                        },
                        {
                          "path": "\/admin\/division\/agent\/applyList",
                          "title": "代理商申请",
                          "icon": "",
                          "header": "",
                          "is_header": 0
                        }
                      ]
                    }
                  ]
                },
                {
                  "path": "\/admin\/kefu",
                  "title": "用户纠错管理",
                  "icon": "md-chatboxes",
                  "header": "",
                  "is_header": 0,
                  "children": [
                    {
                      "path": "\/admin\/setting\/store_service\/index",
                      "title": "客服列表",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/setting\/store_service\/speechcraft",
                      "title": "客服话术",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/setting\/store_service\/feedback",
                      "title": "用户留言",
                      "icon": "",
                      "header": "",
                      "is_header": 0
                    }
                  ]
                },
                {
                  "path": "\/admin\/cms",
                  "title": "政策文件管理",
                  "icon": "ios-book",
                  "header": "home",
                  "is_header": 0,
                  "children": [
                    {
                      "path": "\/admin\/cms\/policy-file\/index",
                      "title": "政策文件管理",
                      "icon": "",
                      "header": "cms",
                      "is_header": 0
                    },
                    {
                      "path": "\/admin\/cms\/policy-file\/add_file",
                      "title": "新增政策文件",
                      "icon": "",
                      "header": "cms",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    }
                  ]
                },
                {
                  "path": "\/admin\/user",
                  "title": "用户管理",
                  "icon": "md-person",
                  "header": "user",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/user\/resident\/list",
                      "title": "居民用户管理",
                      "icon": "",
                      "header": "user",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/user\/resident/details",
                      "title": "用户详情",
                      "icon": "",
                      "header": "user",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    },
                    {
                      "path": "\/admin\/user\/list",
                      "title": "后台用户管理",
                      "icon": "",
                      "header": "user",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/user\/add_admin_user",
                      "title": "新增用户",
                      "icon": "",
                      "header": "user",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    }
                  ]
                },
                // {
                //   "path": "\/admin\/exploration",
                //   "title": "勘探管理",
                //   "icon": "logo-usd",
                //   "header": "exploration",
                //   "is_header": 1,
                //   "children": [
                //     {
                //       "path": "\/admin\/exploration\/task\/list",
                //       "title": "勘探任务",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1
                //     },
                //     {
                //       "path": "\/admin\/exploration\/task\/manager/\list",
                //       "title": "勘探任务管理",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1
                //     },
                //     {
                //       "path": "\/admin\/exploration\/enterprise\/manager/\list",
                //       "title": "勘探企业管理",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1
                //     },
                //     {
                //       "path": "\/admin\/exploration\/add_enterprise",
                //       "title": "新增勘探企业",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1,
                //       "auth": [
                //         "hidden"
                //       ]
                //     },
                //     {
                //       "path": "\/admin\/exploration\/manager/\list",
                //       "title": "勘探管理",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1
                //     },
                //     {
                //       "path": "\/admin\/exploration\/report/results",
                //       "title": "上传勘探结果",
                //       "icon": "",
                //       "header": "exploration",
                //       "is_header": 1,
                //       "auth": [
                //         "hidden"
                //       ]
                //     }
                //   ]
                // },
                // {
                //   "path": "\/admin\/building",
                //   "title": "楼宇信息管理",
                //   "icon": "md-stats",
                //   "header": "building",
                //   "is_header": 1,
                //   "children": [
                //     {
                //       "path": "\/admin\/building\/list",
                //       "title": "楼宇信息管理",
                //       "icon": "",
                //       "header": "building",
                //       "is_header": 1
                //     },
                //     {
                //       "path": "\/admin\/building\/add_building",
                //       "title": "新增楼宇信息管理",
                //       "icon": "",
                //       "header": "building",
                //       "is_header": 1,
                //       "auth": [
                //         "hidden"
                //       ]
                //     }
                //   ]
                // },
                {
                  "path": "\/admin\/basic",
                  "title": "基础数据管理",
                  "icon": "md-stats",
                  "header": "basic",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/basic\/information\/community",
                      "title": "社区管理",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/basic\/information\/add_community",
                      "title": "新增社区",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    },
                    {
                      "path": "\/admin\/basic\/information\/building",
                      "title": "楼宇管理",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/basic\/information\/add_building",
                      "title": "新增楼宇",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    },
                    {
                      "path": "\/admin\/basic\/information\/unit",
                      "title": "单元管理",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/basic\/information\/add_unit",
                      "title": "新增单元",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    },
                    {
                      "path": "\/admin\/basic\/information\/enterprise",
                      "title": "勘探公司管理",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1
                    },
                    {
                      "path": "\/admin\/basic\/information\/add_enterprise",
                      "title": "新增勘探公司",
                      "icon": "",
                      "header": "basic",
                      "is_header": 1,
                      "auth": [
                        "hidden"
                      ]
                    }
                  ]
                },
                {
                  "path": "\/admin\/setting",
                  "title": "系统设置",
                  "icon": "md-settings",
                  "header": "setting",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/setting\/system_role\/index",
                      "title": "角色设置",
                      "icon": "",
                      "header": "setting",
                      "is_header": 1
                    },
                    // {
                    //   "path": "\/admin\/system\/maintain\/system_log\/index",
                    //   "title": "日志管理",
                    //   "icon": "",
                    //   "header": "system",
                    //   "is_header": 0
                    // }
                  ]
                },
                {
                  "path": "\/admin\/system",
                  "title": "权限管理",
                  "icon": "md-hammer",
                  "header": "setting",
                  "is_header": 1,
                  "children": [
                    {
                      "path": "\/admin\/setting\/system_menus\/index",
                      "title": "权限设置",
                      "icon": "",
                      "header": "setting",
                      "is_header": 0
                    },
                  ]
                }
              ],
              "unique_auth": [
                "admin-product",
                "admin-store-storeProuduct-index",
                "admin-store-storeCategory-index",
                "admin-order",
                "admin-order-storeOrder-index",
                "product-product-reply",
                "admin-index-index",
                "admin-user",
                "admin-user-user-index",
                "user-user-level",
                "admin-setting",
                "setting-system-admin",
                "setting-system-role",
                "setting-system-list",
                "setting-system-menus",
                "product-product-save",
                "setting-system-config",
                "admin-system",
                "admin-agent",
                "admin-marketing",
                "setting-system-config",
                "agent-agent-manage",
                "marketing-store_coupon-index",
                "marketing-store_bargain-index",
                "marketing-store_combination-index",
                "marketing-store_seckill-index",
                "marketing-user_point-index",
                "admin-finance",
                "finance-user_extract-index",
                "finance-user-recharge-index",
                "finance-finance-index",
                "finance-user_extract",
                "finance-user-recharge",
                "finance-finance-commission",
                "admin-cms",
                "cms-article-index",
                "cms-article-category",
                "cms-article-creat",
                "system-maintain-system-log",
                "system-config-index",
                "system-clear",
                "system-maintain-system-file",
                "system-maintain-index",
                "system-maintain-system-cleardata",
                "system-maintain-system-databackup",
                "admin-wechat",
                "marketing-store_coupon",
                "marketing-store_coupon_issue",
                "marketing-store_coupon_user",
                "marketing-store_bargain",
                "marketing-store_combination",
                "marketing-store_combination-combina_list",
                "marketing-store_seckill",
                "marketing-store_seckill-data",
                "marketing-integral-system_config",
                "application-wechat-menus",
                "setting-sms",
                "setting-sms-sms-config",
                "setting-sms-config-template",
                "setting-sms-sms-template",
                "product-product-attr",
                "product-save",
                "product-product-index",
                "wechat-wechat-news-category-index",
                "wechat-wechat-news-category-save",
                "system-config-system_config-tab",
                "system-config-system_config-group",
                "wechat-wechat-reply-subscribe",
                "wechat-wechat-reply-index",
                "wechat-wechat-reply-keyword",
                "wechat-wechat-reply-default",
                "system-config-system_config_tab-list",
                "system-config-system_config-list",
                "admin-setting-system_visualization_data",
                "wechat-wechat-reply-save",
                "admin-app",
                "setting-system-config-merchant",
                "setting-freight-express",
                "marketing-store_bargain-create",
                "marketing-store_combination-create",
                "marketing-store_seckill-create",
                "marketing-sign-index",
                "setting-store-service",
                "system-log",
                "product-save-cate",
                "product-product-product_show",
                "product-crawl-save",
                "product-reply-save_fictitious_reply",
                "product-rule-save",
                "product-product-rule-delete",
                "order-write",
                "order-dels",
                "user-user-group",
                "setting-system-city",
                "setting-shipping-templates",
                "admin-order-invoice-index",
                "admin-user-coupon",
                "admin-wechat-news",
                "admin-user-group_set",
                "admin-user-level_add",
                "admin-user-group",
                "admin-marketing-store_coupon-add",
                "admin-marketing-store_coupon-push",
                "setting-merchant-system-store",
                "setting-merchant-system-store-staff",
                "setting-merchant-system-verify-order",
                "setting-system-config-logistics",
                "setting-store_service-add",
                "setting-store_service-edit",
                "setting-system_role-add",
                "setting-system_admin-add",
                " setting-system_admin-edit",
                "setting-system_menus-add",
                "\/setting-system_menus-edit",
                "setting-system_menus-add_sub",
                "setting-sms-sms_template_apply-add",
                "cms-category-create",
                "setting-merchant-system_store-save",
                "merchant-store_staff-create",
                "system-file",
                "system-user",
                "user-user-label",
                "admin-user-label_add",
                "export-storeProduct",
                "export-storeOrder",
                "export-storeSeckill",
                "export-storeCombination",
                "export-storeBargain",
                "export-userAgent",
                "export-userRecharge",
                "system-maintain-auth",
                "product-product-product_show",
                "admin-user-set_label",
                "export-userCommission",
                "system-onlineUpgrade-index",
                "admin-setting-pages",
                "admin-setting-pages-devise",
                "admin-setting-pages-diy",
                "admin-setting-pages-links",
                "admin-setting-diy-additional",
                "admin-setting-pages-diy-save",
                "admin-order-write_update",
                "admin-setting-store_service-index",
                "admin-setting-store_service-speechcraft",
                "admin-marketing-live",
                "admin-marketing-live-live_room",
                "admin-marketing-live-live_goods",
                "admin-marketing-live-anchor",
                "admin-marketing-live-add_live_room",
                "admin-marketing-live-add_live_goods",
                "admin-marketing-live-anchor",
                "live-anchor-add",
                "\/admin\/*",
                "app-wechat-template-sync",
                "admin-statistic",
                "admin-statistic",
                "admin-statistic",
                "marketing-store_coupon_issue-create",
                "setting-delivery-service",
                "setting-delivery_service-edit",
                "setting-delivery_service-add",
                "user-user-grade",
                "user-member_batch-set_value",
                "export-member_card",
                "user-member_card-index",
                "admin-setting-store_service-feedback",
                "admin-setting-store_service-speechcraft-add",
                "admin-setting-store_service-speechcraft-edit",
                "admin-user-member-type",
                "user-member-ship",
                "user-member_ship-save",
                "marketing-store_bargain-bargain_list",
                "admin-user-save",
                "admin-user-synchro",
                "admin-order-offline",
                "admin-order-scan_list",
                "admin-user-grade-card",
                "admin-user-grade-record",
                "user-member-record",
                "admin-user-grade-right",
                "admin-statistic",
                "admin-order-startOrderInvoice-index",
                "admin-order-invoice-edit",
                "admin-order-invoice-orderInfo",
                "admin-order-invoice-update",
                "user-member-right",
                "user-member_right-save",
                "admin-user-user_lable_cate-all",
                "admin-setting-store_service-speechcraft-cate",
                "admin-template",
                "admin-template",
                "admin-order-refund",
                "setting-notification",
                "admin-setting-theme_style",
                "setting-system-pc_data",
                "marketing-store_integral",
                "marketing-store_integral-create",
                "marketing-lottery-index",
                "marketing-store_integral-order",
                "marketing-store_integral-create",
                "admin-routine",
                "routine-download",
                "admin-statistic",
                "finance-capital_flow-index",
                "finance-billing_records-index",
                "admin-user-user-index",
                "marketing-point_record-index",
                "marketing-point_statistic-index",
                "finance-balance-index",
                "finance-user-balance",
                "admin-statistic",
                "setting-system-config",
                "setting-system-config",
                "admin-pc",
                "admin-app",
                "setting-system-config",
                "setting-system-config",
                "setting-storage",
                "agent-division",
                "agent-division-index",
                "agent-division-agent-index",
                "agent-division-agent-applyList",
                "admin-marketing-lottery-create",
                "admin-marketing-lottery-recording_list-id",
                "marketing-channel_code-index",
                "marketing-channel_code-create",
                "marketing-channel_code-statistic",
                "marketing-recharge-index",
                "admin-app-version",
                "setting-other",
                "setting-other-print",
                "setting-other-copy",
                "setting-other-logistics",
                "setting-other-electronic",
                "setting-agreement",
                "setting-other-sms",
                "setting-other-pay",
                "setting-other-out",
                "setting-other-config-out",
                "setting-system-out-account-index",
                "cms-policy-file-index",
                "cms-policy-file-creat",
                "admin-resident-user-index",//居民用户
                "admin-resident-user-view-details",//居民用户详情
                "admin-user-user-index",
                "admin-add-user",
                "admin-user-exports",
                "exploration-task-index",
                "exploration-task-manager-index",
                "exploration-enterprise-manager-index",
                "exploration-add-enterprise",
                "exploration-enterprise-import",
                "exploration-manager-index",
                "report-exploration-results",
                "admin-building-index",
                "admin-add-building",
                "admin-basic-information-community",
                "admin-basic-information-add-community",
                "admin-basic-information-building",
                "admin-basic-information-add-building",
                "admin-basic-information-unit",
                "admin-basic-information-add-unit",
                "admin-basic-information-enterprise",
                "admin-basic-information-add-enterprise"
              ],
              "user_info": {
                "id": 2,
                "account": "admin",
                "head_pic": ""
              },
              "logo": "https:\/\/saishangmilk.oss-cn-zhangjiakou.aliyuncs.com\/attach\/2022\/12\/9d8a4202212141206561193.png",
              "logo_square": "https:\/\/saishangmilk.oss-cn-zhangjiakou.aliyuncs.com\/attach\/2022\/12\/9d8a4202212141206561193.png",
              "version": "LIFT-BZ v4.5.0",
              "newOrderAudioLink": "",
              "queue": false,
              "timer": false
            }
          };

          let data = res.data;
          let expires = this.getExpiresTime(data.expires_time);
          // 记录用户登陆信息
          setCookies('uuid', data.user_info.id, expires);
          setCookies('token', token, expires);
          // setCookies('token', data.token, expires);
          setCookies('expires_time', data.expires_time, expires);

          this.$store.commit('userInfo/uniqueAuth', data.unique_auth);
          this.$store.commit('userInfo/userInfo', data.user_info);
          // 保存菜单信息
          this.$store.commit('menus/setopenMenus', []);
          this.$store.commit('menus/getmenusNav', data.menus);

          // 记录用户信息
          this.$store.commit('userInfo/name', data.user_info.account);
          this.$store.commit('userInfo/avatar', data.user_info.head_pic);
          this.$store.commit('userInfo/access', data.unique_auth);
          this.$store.commit('userInfo/logo', data.logo);
          this.$store.commit('userInfo/logoSmall', data.logo_square);
          this.$store.commit('userInfo/version', data.version);
          this.$store.commit('userInfo/newOrderAudioLink', data.newOrderAudioLink);

          // if (this.jigsaw) this.jigsaw.reset();

          // try {
          //   if (data.queue === false) {
          //     this.$Notice.warning({
          //       title: '温馨提示',
          //       desc: '您的【消息队列】未开启，没有开启会导致异步任务无法执行。请尽快执行命令开启！！',
          //       duration: 30,
          //     });
          //   }
          //   if (data.timer === false) {
          //     this.$Notice.warning({
          //       title: '温馨提示',
          //       desc: '您的【定时任务】未开启，没有开启会导致定时执行的任务无法执行。请尽快执行命令开启！！',
          //       duration: 30,
          //     });
          //   }
          //
          //   this.checkSocket();
          // } catch (e) {}

          return this.$router.replace({ path: '/admin/home/' || '/admin/' });
        })
        .catch((res) => {
          msg();
          this.formInline.code = '';
          let data = res === undefined ? {} : res;
          this.errorNum++;
          this.captchas();
          this.$Message.error(data.msg || '登录失败');
          // if (this.jigsaw) this.jigsaw.reset();
        });
      setTimeout((e) => {
        this.loading = false;
      }, 1000);
    },
    checkSocket() {
      getWorkermanUrl().then((res) => {
        let url = res.data.admin;
        let isNotice = false;
        let socket = new WebSocket(url);
        socket.onopen = () => {
          isNotice = true;
          socket.close();
        };
        socket.onerror = (err) => {
          if (!isNotice) {
            isNotice = true;
            this.$Notice.warning({
              title: '温馨提示',
              desc: '您的【长连接】未开启，没有开启会导致客服消息无法发送,后台订单通知无法收到。请尽快执行命令开启！！',
              duration: 30,
            });
          }
        };
        socket.onclose = (err) => {
          if (!isNotice) {
            isNotice = true;
            this.$Notice.warning({
              title: '温馨提示',
              desc: '您的【长连接】未开启，没有开启会导致客服消息无法发送,后台订单通知无法收到。请尽快执行命令开启！！',
              duration: 30,
            });
          }
        };
      });
    },
    getExpiresTime(expiresTime) {
      let nowTimeNum = Math.round(new Date() / 1000);
      let expiresTimeNum = expiresTime - nowTimeNum;
      return parseFloat(parseFloat(parseFloat(expiresTimeNum / 60) / 60) / 24);
    },
    closefail() {
      // if (this.jigsaw) this.jigsaw.reset();
      this.$Message.error('校验错误');
    },
    handleResize(event) {
      this.fullWidth = document.documentElement.clientWidth;
      if (this.fullWidth < 768) {
        document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
      } else {
        document.getElementsByTagName('canvas')[0].className = 'index_bg';
      }
    },
    captchas: function () {
      this.imgcode = Setting.apiBaseURL + '/captcha_pro?' + Date.parse(new Date());
    },
    handleSubmit(name) {
      this.$refs[name].validate((valid) => {
        if (valid) {
          if (this.errorNum >= 2) {
            this.isShow = true;
          } else {
            this.closeModel();
          }
        }
      });
    },
  },
  beforeCreate() {
    if (this.fullWidth < 768) {
      document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
    } else {
      document.getElementsByTagName('canvas')[0].className = 'index_bg';
    }
  },
  beforeDestroy: function () {
    window.removeEventListener('resize', this.handleResize);
    document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
  },
};
</script>
<style scoped lang="stylus">
.page-account {
  display: flex;
  width: 100%;
  background-image: url('../../../assets/images/bg.jpg');
  background-size: cover;
  background-position: center;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: auto;
}

.page-account .code {
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-account .code .pictrue {
  height: 40px;
}

.swiperPross {
  border-radius: 12px 0px 0px 12px;
}

.swiperPross, .swiperPic, .swiperPic img {
  width: 510px;
  height: 100%;
}

.swiperPic img {
  width: 100%;
  height: 100%;
}

.container {
  height: 400px !important;
  padding: 0 !important;
  border-radius: 12px;
  z-index: 1;
  display: flex;
}

.containerSamll {
  /* width: 56% !important; */
  background: #fff !important;
}

.containerBig {
  width: auto !important;
  background: #f7f7f7 !important;
}

.index_from {
  padding: 0 40px 32px 40px;
  height: 400px;
  box-sizing: border-box;
}

.page-account-top {
  padding: 20px 0 !important;
  box-sizing: border-box !important;
  display: flex;
  justify-content: center;
}

.page-account-container {
  border-radius: 0px 6px 6px 0px;
}

.btn {
  background: linear-gradient(90deg, rgba(25, 180, 241, 1) 0%, rgba(14, 115, 232, 1) 100%) !important;
}

.captchaBox {
  width: 310px;
}

input {
  display: block;
  width: 290px;
  line-height: 40px;
  margin: 10px 0;
  padding: 0 10px;
  outline: none;
  border: 1px solid #c8cccf;
  border-radius: 4px;
  color: #6a6f77;
}

#msg {
  width: 100%;
  line-height: 40px;
  font-size: 14px;
  text-align: center;
}

a:link, a:visited, a:hover, a:active {
  margin-left: 100px;
  color: #0366D6;
}

.index_from >>> .ivu-input-large {
  font-size: 14px !important;
}

.from-wh {
  width: 400px;
}
</style>
